*"Audience Costs in the Eyes of an Adversary"
* Using Stata 16.1
clear
cd
import delimited RAP_Main_US.csv, encoding(UTF-8) 

log using RAP_Main_US_log, replace

***Vairable Codings***
**Experimental Condition
tab regime
tab threat

gen condition=.
replace condition=1 if regime=="democracy" & threat=="that Country A would not take any military action regarding the U.S. bases"
replace condition=2 if regime=="democracy" & threat=="that if the U.S. did not withdraw its military bases in Country B, Country A would bomb and capture them. If the attack is conducted, there is a possibility that hundreds of U.S. soldiers will be killed"
replace condition=3 if regime=="dictatorship" & threat=="that Country A would not take any military action regarding the U.S. bases"
replace condition=4 if regime=="dictatorship" & threat=="that if the U.S. did not withdraw its military bases in Country B, Country A would bomb and capture them. If the attack is conducted, there is a possibility that hundreds of U.S. soldiers will be killed" 
label define condition 1 "No Threat (Dem.)" 2 "Empty Threat (Dem.)" 3 "No Threat (Dic.)" 4 "Empty Threat (Dic.)"
label values condition condition
tab condition

**Demographics
*Gender
tab gender
g Male=.
replace Male=1 if gender=="Male"
replace Male=0 if gender=="Female"
tab Male

*Age
tab age
g Age=.
replace Age=1 if age>=18 & age<=24
replace Age=2 if age>=25 & age<=34
replace Age=3 if age>=35 & age<=44
replace Age=4 if age>=45 & age<=54
replace Age=5 if age>=55 & age<=64
replace Age=6 if age>=65
tab Age

label define Age 1 "18-24" 2 "25-34" 3 "35-44" 4 "45-54" 5 "55-64" 6 "65 or Over"
label values Age Age

*Race
tab race
g White=.
replace White=1 if race=="White"
replace White=0 if race=="Asian" | race=="Black" | race=="Mixed" | race=="Other" 
sum White
label define White 1 "White" 0 "Non Whites"
label values White White
tab White

*Ideology(Respondent)
tab ideology
g Ideology=.
replace Ideology=1 if ideolog=="Extremely Conservative"
replace Ideology=2 if ideolog=="Conservative"
replace Ideology=3 if ideolog=="Slightly Conservative"
replace Ideology=4 if ideolog=="Moderate, Middle of the Road"
replace Ideology=5 if ideolog=="Slightly Liberal"
replace Ideology=6 if ideolog=="Liberal"
replace Ideology=7 if ideolog=="Extremely Liberal"
tab Ideology
sum Ideology

label define Ideology 1 "Extremely Conservative" 2 "Conservative" 3 "Slightly Conservative" 4 "Moderate, Middle of the Road/Don't Know" 5 "Slightly Liberal" 6 "Liberal" 7 "Extremely Liberal"
label values Ideology Ideology
tab Ideology

*Income
tab income
g Income=.
replace Income=1 if income=="Less than $25,000"
replace Income=2 if income=="$25,000 - $49,999"
replace Income=3 if income=="$50,000 - $74,999"
replace Income=4 if income=="$75,000 - $99,999"
replace Income=5 if income=="$100,000 - $124,999"
replace Income=6 if income=="$125,000 - $149,999"
replace Income=7 if income=="$150,000 - $174,999"
replace Income=8 if income=="$175,000 - $199,999"
replace Income=9 if income=="More than $200,000"
tab Income

label define Income 1 "Less than $25,000" 2 "$25,000 - $49,999" 3 "$50,000 - $74,999" 4 "$75,000 - $99,999" 5 "$100,000 - $124,999" 6 "$125,000 - $149,999" 7 "$150,000 - $174,999" 8 "$175,000 - $199,999" 9 "More than $200,000"
label values Income Income
tab Income

*Education
tab education
gen Education=.
replace Education=1 if education=="Bachelor’s degree or higher"
replace Education=0 if education!="Bachelor’s degree or higher"
replace Education=. if education=="Prefer not to answer"

label define Education 1 "Bachelor’s degree or higher" 0 "Less than Bachelor’s degree"
label values Education Education
tab Education

*Partisanship
tab partisanship
g Democrat=.
replace Democrat=1 if partisanship=="Democrat"
replace Democrat=0 if partisanship!="Democrat"
replace Democrat=. if partisanship=="Prefer not to answer"
label define Democrat 1 "Democrat" 0 "Not Democrat"
label values Democrat Democrat
tab Democrat

g Republican=.
replace Republican=1 if partisanship=="Republican"
replace Republican=0 if partisanship!="Republican"
replace Republican=. if partisanship=="Prefer not to answer"
label define Republican 1 "Republican" 0 "Not Republican"
label values Republican Republican
tab Republican

*Voting
tab voting
gen Voting_Pres24=.
replace Voting_Pres24=1 if voting=="Yes"
replace Voting_Pres24=0 if voting=="No"
tab Voting_Pres24

*Empathy
gen emp1=.
replace emp1=1 if emp_1=="1. Does Not Describe Me Well"
replace emp1=2 if emp_1=="2"
replace emp1=3 if emp_1=="3"
replace emp1=4 if emp_1=="4"
replace emp1=5 if emp_1=="5. Describes Me Very Well"
tab emp1

gen emp2=.
replace emp2=1 if emp_2=="1. Does Not Describe Me Well"
replace emp2=2 if emp_2=="2"
replace emp2=3 if emp_2=="3"
replace emp2=4 if emp_2=="4"
replace emp2=5 if emp_2=="5. Describes Me Very Well"
tab emp2

gen emp3=.
replace emp3=1 if emp_3=="1. Does Not Describe Me Well"
replace emp3=2 if emp_3=="2"
replace emp3=3 if emp_3=="3"
replace emp3=4 if emp_3=="4"
replace emp3=5 if emp_3=="5. Describes Me Very Well"
tab emp3

gen Emp=emp1+emp2+emp3
tab Emp

**Threat Credibility (Dummy)
tab s1_credibility

gen Cred_Dummy=.
replace Cred_Dummy=1 if s1_credibility=="Very likely"|s1_credibility=="Likely"
replace Cred_Dummy=0 if s1_credibility=="Very unlikely"|s1_credibility=="Unlikely"

tab Cred_Dummy

**Threat Credibility (Continuous)
gen Cred_Cont=.
replace Cred_Cont=4 if s1_credibility=="Very likely"
replace Cred_Cont=3 if s1_credibility=="Likely"
replace Cred_Cont=2 if s1_credibility=="Unlikely"
replace Cred_Cont=1 if s1_credibility=="Very unlikely"

tab Cred_Cont

*Situational Support (Dummy)
gen SA_Dummy=.
replace SA_Dummy=1 if s2_sa=="Approve"
replace SA_Dummy=0 if s2_sa=="Disapprove"
replace SA_Dummy=0 if s2_sa=="Neither approve nor disapprove"

tab SA_Dummy

*Situational Support (Continuous)
gen SA_Cont=.
replace SA_Cont=7 if s2_sa=="Approve" & s2_sa_approve=="Very strongly"
replace SA_Cont=6 if s2_sa=="Approve" & s2_sa_approve=="Somewhat"
replace SA_Cont=5 if s2_sa=="Neither approve nor disapprove" & s2_sa_neither=="Lean toward approving"
replace SA_Cont=4 if s2_sa=="Neither approve nor disapprove" & s2_sa_neither=="Don't lean either way"
replace SA_Cont=3 if s2_sa=="Neither approve nor disapprove" & s2_sa_neither=="Lean toward disapproving"
replace SA_Cont=2 if s2_sa=="Disapprove" & s2_sa_disapprove=="Somewhat"
replace SA_Cont=1 if s2_sa=="Disapprove" & s2_sa_disapprove=="Very strongly"

tab SA_Cont

*General Support (Dummy)
gen GA_Dummy=.
replace GA_Dummy=1 if s2_ga=="Approve"
replace GA_Dummy=0 if s2_ga=="Disapprove"
replace GA_Dummy=0 if s2_ga=="Neither approve nor disapprove"

tab GA_Dummy

*General Support (Continuous)
gen GA_Cont=.
replace GA_Cont=7 if s2_ga=="Approve" & s2_ga_approve=="Very strongly"
replace GA_Cont=6 if s2_ga=="Approve" & s2_ga_approve=="Somewhat"
replace GA_Cont=5 if s2_ga=="Neither approve nor disapprove" & s2_ga_neither=="Lean toward approving"
replace GA_Cont=4 if s2_ga=="Neither approve nor disapprove" & s2_ga_neither=="Don't lean either way"
replace GA_Cont=3 if s2_ga=="Neither approve nor disapprove" & s2_ga_neither=="Lean toward disapproving"
replace GA_Cont=2 if s2_ga=="Disapprove" & s2_ga_disapprove=="Somewhat"
replace GA_Cont=1 if s2_ga=="Disapprove" & s2_ga_disapprove=="Very strongly"

tab GA_Cont

**Conditions
gen Threat=0
replace Threat=1 if condition==2|condition==4

label define Threat 0 "No Threat" 1 "Empty Threat"
label values Threat Threat
tab Threat

gen Democracy=0
replace Democracy=1 if condition==1|condition==2

label define Democracy 0 "Dictatorship" 1 "Democracy"
label values Democracy Democracy
tab Democracy

***The Observations of Each Condition
tab condition

**Tests of H1
ttest SA_Dummy, by(Threat)

***Plot
anova SA_Dummy condition
pwmean SA_Dummy, over(condition) mcompare(tukey) effects

anova SA_Dummy condition
margins condition

marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "main.pdf", replace	
	
**Test for H2
reg SA_Dummy i.Threat##i.Democracy	
	
	
anova SA_Cont condition
pwmean SA_Cont, over(condition) mcompare(tukey) effects

anova GA_Dummy condition
pwmean GA_Dummy, over(condition) mcompare(tukey) effects

anova GA_Cont condition
pwmean GA_Cont, over(condition) mcompare(tukey) effects

*The Conditional Effect (Approval)
reg SA_Dummy i.Threat##i.Democracy
reg SA_Cont i.Threat##i.Democracy
reg GA_Dummy i.Threat##i.Democracy
reg GA_Cont i.Threat##i.Democracy

**Test: Multiple Comparison (Credibility)
anova Cred_Dummy condition
pwmean Cred_Dummy, over(condition) mcompare(tukey) effects

anova Cred_Dummy condition
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "main_cred.pdf", replace

reg Cred_Dummy i.Threat##i.Democracy

anova Cred_Cont condition
pwmean Cred_Cont, over(condition) mcompare(tukey) effects

**Descriptive Statistics
sum i.condition SA_Dummy SA_Cont GA_Dummy GA_Cont Cred_Dummy Cred_Cont Male Age White Ideology Democrat Republican Voting_Pres24 Income Education Emp

**Balance Check
ttesttable Male condition, ref(1) uneq
ttesttable Age condition, ref(1) uneq
ttesttable White condition, ref(1) uneq
ttesttable Democrat condition, ref(1) uneq
ttesttable Republican condition, ref(1) uneq
ttesttable Ideology condition, ref(1) uneq
ttesttable Voting_Pres24 condition, ref(1) uneq
ttesttable Income condition, ref(1) uneq
ttesttable Education condition, ref(1) uneq
ttesttable Emp condition, ref(1) uneq

**OLS (without Covariates)
reg SA_Dummy i.Threat##i.Democracy 
estimates store Model1

reg SA_Cont i.Threat##i.Democracy
estimates store Model2

reg GA_Dummy i.Threat##i.Democracy
estimates store Model3

reg GA_Cont i.Threat##i.Democracy 
estimates store Model4

reg Cred_Dummy i.Threat##i.Democracy
estimates store Model5

reg Cred_Cont i.Threat##i.Democracy
estimates store Model6

esttab Model1 Model2 Model3 Model4 Model5 Model6 using covariants.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Controlling for Demographic and Attitudinal Variables
reg SA_Dummy i.Threat##i.Democracy Male Age White Ideology Democrat Republican Income Voting_Pres24 Education Emp
estimates store Model1

reg SA_Cont i.Threat##i.Democracy Male Age White Ideology Democrat Republican Income Voting_Pres24 Education Emp
estimates store Model2

reg GA_Dummy i.Threat##i.Democracy Male Age White Ideology Democrat Republican Income Voting_Pres24 Education Emp
estimates store Model3

reg GA_Cont i.Threat##i.Democracy Male Age White Ideology Democrat Republican Income Voting_Pres24 Education Emp
estimates store Model4

reg Cred_Dummy i.Threat##i.Democracy Male Age White Ideology Democrat Republican Income Voting_Pres24 Education Emp
estimates store Model5

reg Cred_Cont i.Threat##i.Democracy Male Age White Ideology Democrat Republican Income Voting_Pres24 Education Emp
estimates store Model6

esttab Model1 Model2 Model3 Model4 Model5 Model6 using covariants.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Exclude inattentive subjects
tab attention
sum durationinseconds, detail

*Drop if the response time is below 5% percentile or above 95% percentile
g inattentive=0
replace inattentive=1 if durationinseconds<175 | durationinseconds>872 
tab inattentive

anova SA_Dummy condition if inattentive==0 
pwmean SA_Dummy if inattentive==0 , over(condition) mcompare(tukey) effects

anova SA_Dummy condition if inattentive==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_inattentive.pdf", replace

anova Cred_Dummy condition if inattentive==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_inattentive.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if inattentive==0
estimates store Model1

reg Cred_Dummy i.Threat##i.Democracy if inattentive==0
estimates store Model2

esttab Model1 Model2 using inattentive.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Manupulation Checks
*mc1: In the scenario you previously read, is Country A a democracy or a dictatorship? (G1 and G2: Yes, G3 and G4: No)
*mc2: In the scenario you previously read, did the leader of Country A issue a military threat to attack the U.S. bases? (G1 and G3: No, G2 and G4: Yes)
tab mc1
tab mc2
gen manipulation=0
replace manipulation=1 if condition==1 & mc1=="Democracy" & mc2=="No"
replace manipulation=1 if condition==2 & mc1=="Democracy" & mc2=="Yes"
replace manipulation=1 if condition==3 & mc1=="Dictatorship" & mc2=="No"
replace manipulation=1 if condition==4 & mc1=="Dictatorship" & mc2=="Yes"
tab manipulation
tab condition manipulation, row


anova SA_Dummy condition if manipulation==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_manu.pdf", replace

anova Cred_Dummy condition if manipulation==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_manu.pdf", replace	
	
reg SA_Dummy i.Threat##i.Democracy if manipulation==1
estimates store Model1

reg Cred_Dummy i.Threat##i.Democracy if manipulation==1
estimates store Model2

esttab Model1 Model2 using manipulation.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

***Specific Countries?
tab specific_1
tab specific_2
tab specific_2_4_text

gen specific=.
replace specific=0 if specific_1=="No"
replace specific=1 if specific_1=="Yes"

anova SA_Dummy condition if specific==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_nospecific.pdf", replace	
	
anova SA_Dummy condition if specific==1 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_specific.pdf", replace

anova Cred_Dummy condition if specific==0
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_nospecific.pdf", replace

anova Cred_Dummy condition if specific==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_specific.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if specific==0
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if specific==1
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if specific==0
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if specific==1
estimates store Model4

esttab Model1 Model2 Model3 Model4 using specific.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)
	
***The Heterogenous Effect of Demographic and Attitudinal Variables
**Conditional Effect of Gender?
anova SA_Dummy condition if Male==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_notmale.pdf", replace

anova SA_Dummy condition if Male==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_male.pdf", replace


anova Cred_Dummy condition if Male==0
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_notmale.pdf", replace

anova Cred_Dummy condition if Male==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_male.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if Male==0
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if Male==1
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if Male==0
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if Male==1
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_male.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Conditional Effect of Age? (Old: Above the mean)
sum Age
gen Old=.
replace Old=1 if Age>=4
replace Old=0 if Age<4
tab Old

anova SA_Dummy condition if Old==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_notold.pdf", replace

anova SA_Dummy condition if Old==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_old.pdf", replace


anova Cred_Dummy condition if Old==0
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_notold.pdf", replace

anova Cred_Dummy condition if Old==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_old.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if Old==0
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if Old==1
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if Old==0
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if Old==1
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_old.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Conditional Effect of White?
anova SA_Dummy condition if White==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_nowhite.pdf", replace

anova SA_Dummy condition if White==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_white.pdf", replace


anova Cred_Dummy condition if White==0
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_nowhite.pdf", replace

anova Cred_Dummy condition if White==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_white.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if White==0
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if White==1
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if White==0
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if White==1
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_white.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)


**Conditional Effect of Ideology?
sum Ideology
gen Liberal=.
replace Liberal=1 if Ideology>5
replace Liberal=0 if Ideology<=5
tab Liberal

anova SA_Dummy condition if Liberal==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_nolib.pdf", replace

anova SA_Dummy condition if Liberal==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_lib.pdf", replace


anova Cred_Dummy condition if Liberal==0
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_nolib.pdf", replace

anova Cred_Dummy condition if Liberal==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_lib.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if Liberal==0
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if Liberal==1
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if Liberal==0
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if Liberal==1
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_lib.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Conditional Effect of Democrat?
anova SA_Dummy condition if Democrat==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval ") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_nodem.pdf", replace

anova SA_Dummy condition if Democrat==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_dem.pdf", replace


anova Cred_Dummy condition if Democrat==0
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_nodem.pdf", replace

anova Cred_Dummy condition if Democrat==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_dem.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if Democrat==0
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if Democrat==1
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if Democrat==0
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if Democrat==1
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_dem.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)


**Conditional Effect of Republican?
anova SA_Dummy condition if Republican==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_norep.pdf", replace

anova SA_Dummy condition if Republican==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_rep.pdf", replace


anova Cred_Dummy condition if Republican==0
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_norep.pdf", replace

anova Cred_Dummy condition if Republican==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_rep.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if Republican==0
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if Republican==1
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if Republican==0
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if Republican==1
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_rep.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Conditional Effect of Voting in 2024 Presidential Election?
anova SA_Dummy condition if Voting_Pres24==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_nopres24.pdf", replace

anova SA_Dummy condition if Voting_Pres24==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_pres24.pdf", replace

anova Cred_Dummy condition if Voting_Pres24==0
pwmean Cred_Dummy if Voting_Pres24==0, over(condition) mcompare(tukey) effects

anova Cred_Dummy condition if Voting_Pres24==0
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_nopres24.pdf", replace

anova Cred_Dummy condition if Voting_Pres24==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_pres24.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if Voting_Pres24==0
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if Voting_Pres24==1
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if Voting_Pres24==0
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if Voting_Pres24==1
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_pres24.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Conditional Effect of Income? (Above the mean or nor)
sum Income
gen High_Income=.
replace High_Income=1 if Income>3
replace High_Income=0 if Income<=3
tab High_Income

anova SA_Dummy condition if High_Income==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_lowincome.pdf", replace

anova SA_Dummy condition if High_Income==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_highincome.pdf", replace


anova Cred_Dummy condition if High_Income==0
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_lowincome.pdf", replace

anova Cred_Dummy condition if High_Income==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_highincome.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if High_Income==0
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if High_Income==1
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if High_Income==0
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if High_Income==1
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_income.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Conditional Effect of Education?
anova SA_Dummy condition if Education==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_lowedu.pdf", replace

anova SA_Dummy condition if Education==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_highedu.pdf", replace


anova Cred_Dummy condition if Education==0
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_lowedu.pdf", replace

anova Cred_Dummy condition if Education==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_highedu.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if Education==0
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if Education==1
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if Education==0
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if Education==1
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_edu.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Conditional Effect of Empathy?
sum Emp

*Generate a dummy variable of the high level of empathy when the value is above the mean
gen HighEmpathy=.
replace HighEmpathy=1 if Emp>12
replace HighEmpathy=0 if Emp<=12
tab HighEmpathy

anova SA_Dummy condition if HighEmpathy==0 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_lowemp.pdf", replace

anova SA_Dummy condition if HighEmpathy==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_highemp.pdf", replace


anova Cred_Dummy condition if HighEmpathy==0
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_lowemp.pdf", replace

anova Cred_Dummy condition if HighEmpathy==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_highemp.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if HighEmpathy==0
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if HighEmpathy==1
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if HighEmpathy==0
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if HighEmpathy==1
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_emp.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

***Conditional Effect of Other Covariates Randomized in the Scenario
**Conditional Effect of Military Strength
tab military
encode military, generate(Military)

anova SA_Dummy condition if Military==1 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_strongmil.pdf", replace

anova SA_Dummy condition if Military==2
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_weakmil.pdf", replace


anova Cred_Dummy condition if Military==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_strongmil.pdf", replace

anova Cred_Dummy condition if Military==2
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_weakmil.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if Military==1
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if Military==2
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if Military==1
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if Military==2
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_mil.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Conditional Effect of Motives
tab motive
encode motive, generate(Motive)
label drop Motive
label define Motive 1 "Intangible" 2 "Tangible"
label values Motive Motive
tab Motive

anova SA_Dummy condition if Motive==1 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_intanmot.pdf", replace

anova SA_Dummy condition if Motive==2
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_tanmot.pdf", replace


anova Cred_Dummy condition if Motive==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_intanmot.pdf", replace

anova Cred_Dummy condition if Motive==2
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_tanmot.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if Motive==1
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if Motive==2
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if Motive==1
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if Motive==2
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_mot.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Conditional Effect of Interest
tab interest
encode interest, generate(Interest)
label drop Interest
label define Interest 1 "Strong" 2 "Weak"
label values Interest Interest
tab Interest

anova SA_Dummy condition if Interest==1 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_strongint.pdf", replace

anova SA_Dummy condition if Interest==2
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_weakint.pdf", replace


anova Cred_Dummy condition if Interest==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_strongint.pdf", replace

anova Cred_Dummy condition if Interest==2
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_weakint.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if Interest==1
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if Interest==2
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if Interest==1
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if Interest==2
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_int.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

**Conditional Effect of Region
tab region
encode region, generate(Region)
label drop Region
label define Region 1 "Europe" 2 "Middle East"
label values Region Region
tab Region

anova SA_Dummy condition if Region==1 
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_europe.pdf", replace

anova SA_Dummy condition if Region==2
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Situational Approval") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "pac_me.pdf", replace


anova Cred_Dummy condition if Region==1
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_europe.pdf", replace

anova Cred_Dummy condition if Region==2
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)0.6) ///
	ytitle("Perceived Likelihood of Military Action") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "cred_me.pdf", replace

reg SA_Dummy i.Threat##i.Democracy if Region==1
estimates store Model1

reg SA_Dummy i.Threat##i.Democracy if Region==2
estimates store Model2

reg Cred_Dummy i.Threat##i.Democracy if Region==1
estimates store Model3

reg Cred_Dummy i.Threat##i.Democracy if Region==2
estimates store Model4

esttab Model1 Model2 Model3 Model4 using hetero_reg.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

***Mechanisms
**Competency
tab competency
gen Competency=.
replace Competency=0 if competency=="No"
replace Competency=1 if competency=="Yes"
label define Competency 0 "No" 1 "Yes"
label values Competency Competency
tab Competency

anova Competency condition
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Proportion (Competency)") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "competency.pdf", replace

**Credibility
tab credibility
gen Credibility=.
replace Credibility=0 if credibility=="No"
replace Credibility=1 if credibility=="Yes"
label define Credibility 0 "No" 1 "Yes"
label values Credibility Credibility
tab Credibility

anova Credibility condition
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Proportion (Credibility)") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "credibility.pdf", replace

**Reputation
tab reputation
gen Reputation=.
replace Reputation=0 if reputation=="No"
replace Reputation=1 if reputation=="Yes"
label define Reputation 0 "No" 1 "Yes"
label values Reputation Reputation
tab Reputation

anova Reputation condition
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Proportion (Reputation)") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "reputation.pdf", replace

**Morality
tab morality
gen Morality=.
replace Morality=0 if morality=="No"
replace Morality=1 if morality=="Yes"
label define Morality 0 "No" 1 "Yes"
label values Morality Morality
tab Morality

anova Morality condition
margins condition
marginsplot, ///
    recast(scatter) ///
    recastci(rcap) ///
    xsize(3.7) ///
    xlabel(, angle(45) labsize(small)) ///
    yscale(range(0 .)) ///
    ylabel(0(0.1)1) ///
	ytitle("Proportion (Morality)") ///
	xtitle("") ///
    title("") ///
    subtitle("") ///
    legend(off)

graph export "morality.pdf", replace

reg Competency i.Threat##i.Democracy
estimates store Model2

reg Credibility i.Threat##i.Democracy
estimates store Model1

reg Reputation i.Threat##i.Democracy
estimates store Model3

reg Morality i.Threat##i.Democracy
estimates store Model4

esttab Model1 Model2 Model3 Model4 using mechanisms.tex, replace se r2 legend label collabels(none) varlabels(_cons Constant) star(* 0.05 ** 0.01)

log close